#!/bin/bash

manage_file="./webroot/AutoSa/manage.py"
log_handler_file="./webroot/AutoSa/log_handler.py"
websocket_file="./webroot/AutoSa/websocket/index.js"

which node &> /dev/null
if [ $? != '0' ];then
    echo "Please define the node.js binary file 'node' in the PATH."
    exit
fi
node $websocket_file &
if [ -f $manage_file -a -e $manage_file ] && [ -f $log_handler_file -a -e $log_handler_file ];then
    $manage_file runserver 0.0.0.0:80 &> logs/access.log &
    $log_handler_file &> logs/handler.log   &
else
    echo "manage.py or log_handler.py isn't exist or executable."
fi
